use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct Struct yata::indicators::EaseOfMovement Ease Of Movement
///
///  参见[EOM](https://www.investopedia.com/terms/e/easeofmovement.asp)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct EOM {
    /// 1 signal
    ///
    /// Signal 1 appears when main value crosses zero line.
    ///
    /// When main value crosses zero line upwards, returns full buy signal.
    ///
    /// When main value crosses zero line downwards, returns full sell signal.
    ///
    pub signal0: Option<IndicatorActionWrap>,

    ///1 value
    ///Main value
    ///Range in (-inf; +inf)
    pub main: ValueType,
}

/// Configuration Ease Of Movement
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct EOMConfig {
    ///     ma: M
    /// Main moving average type.
    ///
    /// Default is SMA(13)
    ///
    /// Period range in [2; PeriodType::MAX).
    pub ma: PeriodType,

    /// period2: PeriodType
    /// Differencial period size. Default is 1.
    ///
    /// Range in [1; PeriodType::MAX].
    pub period2: PeriodType,
}

impl Default for EOMConfig {
    fn default() -> Self {
        Self { ma: 13, period2: 1 }
    }
}
